
#include<iostream>

class Base
{
public:
    Base()
    {
        std::cout<<"父类构造函数"<<std::endl;
        a = new int;
    }
    ~Base()
    {
        std::cout<<"父类析构函数"<<std::endl;
        delete a;
    }
private:
    int *a;
};

class Derived:public Base
{
    public:
    Derived():Base()
    {

    }

    ~Derived(){std::cout<<"子类析构函数"<<std::endl;}
private:
    int *b;
};

int main()
{
    Derived *d = new Derived;
    delete d;
    return 0;
}

//delete 调用的是基类析构函数